const util = require('../../utils/util')
const chooseLocation = requirePlugin('chooseLocation');
var utilBB = require("../../utils/util_getBasketBall")
var utilBBpm = require("../../utils/util_getBasketBallPm")
Page({

  /**
   * 页面的初始数据
   */
  data: {
    address: "",
    locationName: "",
    x:true,
    rq:[],
    i:"0",
    shuju:[],
    result:[],
    dongbu:[],
    xibu:[],
    startDate: null,
    endDate: new Date().getFullYear() + '-12-31',
    currentDate: util.formatTime(new Date(), '-', false),

  },
  getBasketBall:function(){
    var that = this;
    utilBB.getBasketBallData(function(res){
      console.log(res)
      
      that.setData({
        result:res.result,
        rq:res.result.matchs,
        shuju:res.result.matchs[1].list
      });
   
    });
},
  getBasketBallPm:function(){
    var that = this;
    utilBBpm.getBasketBallPmData(function(res){
      
      that.setData({
        dongbu:res.result.ranking[0],
        xibu:res.result.ranking[1]
        
      });    
    });
  },
  
  bindDateChange: function (e) {
    console.log(e.detail.value)
    this.setData({
      currentDate:e.detail.value
    }) 
  
    if (e.detail.value == this.data.rq[0].date){
      this.setData({
        shuju:this.data.rq[0].list
      })
    }
    else if (e.detail.value == this.data.rq[1].date){
      this.setData({
        shuju:this.data.rq[1].list
      })
    }
    else if (e.detail.value == this.data.rq[2].date){
      this.setData({
        shuju:this.data.rq[2].list
      })
    }
    else if (e.detail.value == this.data.rq[3].date){
      this.setData({
        shuju:this.data.rq[3].list
      })
    }
    else if (e.detail.value == this.data.rq[4].date){
      this.setData({
        shuju:this.data.rq[4].list
      })
    }
    else if (e.detail.value == this.data.rq[5].date){
      this.setData({
        shuju:this.data.rq[5].list
      })
    }
    else{
      this.setData({
        shuju:this.data.rq[6].list
      })
    }
  },
  
  onclick1:function(){
    var x = this.data.x
    if(x==false){
      this.setData({
        x:true
      })
    }
    else if(x==true){
      this.setData({
        x:false
      })
    }

  },

  


  talk:function(){
    wx.navigateTo({
      url: '/pages/football/talk/talk',
    })

  },


  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.getBasketBall();
    this.getBasketBallPm();

  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    const location = chooseLocation.getLocation();
    if(location){
        this.setData({
            address: location.address?location.address : "",
            locationName: location.name?location.name : ""
        });
    }
    

  },
 
  showMap() {
    //使用在腾讯位置服务申请的key（必填）
    const key = ""; 
    //调用插件的app的名称（必填）
    const referer = ""; 
    wx.navigateTo({
        url: 'plugin://chooseLocation/index?key=' + '673BZ-GQS6D-R6G4H-HVDVX-XOHG2-BMBBJ' + '&referer=' + 'xiaobin'
    });
},

showGh(){
let plugin = requirePlugin('routePlan');
let key = '673BZ-GQS6D-R6G4H-HVDVX-XOHG2-BMBBJ';  //使用在腾讯位置服务申请的key
let referer = 'xiaobin';   //调用插件的app的名称
let endPoint = JSON.stringify({  //终点
    'name': '',
    'latitude': 39.89631551,
    
});

wx.navigateTo({
    url: 'plugin://routePlan/index?key=' + key + '&referer=' + referer + '&endPoint=' + endPoint
});
},

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})